<template>
	<view class="h-[calc(100vh-44px)] py-2 px-3 flex flex-col">
		<uv-form labelPosition="top" labelWidth="auto" :model="formModel" ref="formRef" :labelStyle="labelStyle" class="flex-1">
			<uv-form-item label="库位条码" prop="pickUpForm.storageLocationName" borderBottom>
				<uv-input v-model="formModel.pickUpForm.storageLocationName" border="none" />
			</uv-form-item>
			<uv-form-item label="单号" prop="pickUpForm.courierNumber" borderBottom>
				<uv-input v-model="formModel.pickUpForm.courierNumber" border="none" />
			</uv-form-item>
			<div class="grid grid-cols-2 gap-5">
				<uv-button type="primary" customStyle="margin-top: 10px" @click="submit">新增</uv-button>
				<uv-button type="error" customStyle="margin-top: 10px" @click="reset">重置</uv-button>
			</div>
		</uv-form>
	</view>
</template>

<script setup>
	import { addsign } from '@/api/modules/sign.js'
	
	const labelStyle = {
		color: '#ccc',
		fontSize: '14px'
	}
	const formRef = ref(null); // form实例
	const formModel = ref({
		pickUpForm: {
			storageLocationName: '', // 库位条码
			courierNumber: '' // 单号
		}
	})
	// 提交 新增快递签收
	const submit = () => {
		addsign(formRef.value.model.pickUpForm).then(res => {
			if(res.code === 200) {
				// 操作成功, 跳转回主页面
				setTimeout(() => {
					uni.navigateTo({ url: '/pages/index/index' })
				}, 2000)
			}
		}).catch(err => {
			uni.showToast({ title: `操作失败!`, icon: 'error' })
		})
	}
	
	// 重置
	const reset = () => {
		formRef.value.resetFields()
	}
</script>

<style>

</style>
